
(defun dolist (l fn)
  (let ((it (iterator l)))
    (while (it-has-next it)
      (apply fn (list (it-next it) $rest)))))

(defun dotimes (n fn)
  (let ((i 0))
    (while (< i n)
      (apply fn (list i $rest))
      (setq i (+ i 1)))))

(defun map (l fn)
  (let ((ret ()))
    (println ret)
    (dolist l
      (lambda (i)
	(append ret (apply fn i $rest))))
    ret))

(defun not (sexp)
  (if sexp false true))

(setq java.util.Arrays.asList (get-method (class "java.util.Arrays") "asList" (list object[].class)))
(defun array-to-list (arr)
  (invoke java.util.Arrays.asList nil (list arr)))

(setq java.lang.Class.getMethods (get-method (class "java.lang.Class") "getMethods" ()))
(defun get-methods (clazz)
  (array-to-list (invoke java.lang.Class.getMethods clazz ())))

(setq java.lang.Class.getConstructors (get-method (class "java.lang.Class") "getConstructors" ()))
(defun get-constructors (clazz)
  (array-to-list (invoke java.lang.Class.getConstructors clazz ())))

(setq java.lang.reflect.Method.getName (get-method (class "java.lang.reflect.Method") "getName" ()))
(defun method-name (method)
  (invoke java.lang.reflect.Method.getName method ()))

;(defun import-class (name)
;  (let ((cls (class name)))
;    (dolist (get-methods cls)
;      (lambda (m)
;	(let ((sym (intern (to-upper-case (strcat name "." (method-name m))))))
